<template>
 <div>
    <div>

      <el-button @click="addgoodsif">重新鉴定</el-button>

    </div>

      <el-table :data="goodsifs" :row-class-name="tableRowClassName" @selection-change="handleSelectionChange">
        <!-- 表格中多选框组件 -->
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column prop="identifyId" label="序列号" width="140">
        </el-table-column>
        <el-table-column prop="identifyResult" :formatter="IsRe" label="鉴定真假" width="120">
        </el-table-column>
        <el-table-column prop="goodsQuality" label="新旧程度" width="120">
        </el-table-column>
        <el-table-column prop="createBy" label="评估人" width="120">
        </el-table-column>

        <el-table-column prop="identifyDesc" label="备注" width="120">
        </el-table-column>

      </el-table>


      <!-- //分页插件 -->
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page.sync="pages.current" :page-size="pages.size" layout="total, prev, pager, next"
        :total="pages.total">
      </el-pagination>
      <!-- 修改店铺弹框 -->


      <!-- 新增门店 弹框-->
      <el-dialog title="重新鉴定" :visible.sync="addShopFormVisible" @close="shopClose">
        <el-form label-width="80px">
          <p>新旧程度</p>
          <el-select v-model="shopStat1" placeholder="请选择" style="position: absolute;left: 0px;">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
          <el-form-item label="真假">
            <template>
              <el-radio v-model="goodsif.identifyResult" label="1">真</el-radio>
              <el-radio v-model="goodsif.identifyResult" label="0">假</el-radio>
            </template>
          </el-form-item>

          <el-form-item label="备注" prop="identifyDesc">
            <el-input type="textarea" v-model="goodsif.identifyDesc"></el-input>
          </el-form-item>


        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="addShopFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="addshopOk">添加</el-button>
        </div>
      </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "goodsif",
    props: ["selectGoodsId"],
    data() {
      return {
        options: [
          {
            value: '5成',
            label: '5成'
          }, {
            value: '6成',
            label: '6成'
          }, {
            value: '7成',
            label: '7成',
          },
          {
            value: '8成',
            label: '8成'
          },
          {
            value: '9成',
            label: '9成'
          },
        ],
        goodsifs: [],
        goodsif: {
          identifyId: "",
          goodsId: "",
          procInstId: "",
          goodsQuality: "",
          identifyDesc: "",
          identifyResult: "",
          createBy: "",
          createTime: "",
          stat: "",

        },
        username: "",
        current: "",
        size: "",
        pages: null,
        addShopFormVisible: false,
        shopStat1: "",
      }
    },
    methods: {
      addgoodsif() {
        this.addShopFormVisible = true;
      },

      shopClose() {
        this.addShopFormVisible = false;
      },
      getGoodsifbygid(current, size) {
        this.$http.get("/pawnGoodsIdentifyLog/findgoodsif", {
          params: {
            goodsId: this.selectGoodsId,
            current: current,
            size: size
          }
        }).then(resp => {
          console.log(resp)
          this.goodsifs = resp.data.data.records
          this.pages = resp.data.data
          this.current = resp.data.data.current
          this.size = resp.data.data.size
          // this.whName = resp
        })
      },
      addshopOk() {
        let s = localStorage.getItem("loginAccount");
        this.username = JSON.parse(s).accountUsername;
        alert(this.username)
        this.$http.post("/pawnGoodsIdentifyLog/addgoodsif", {
          goodsId: this.selectGoodsId,
          goodsQuality: this.shopStat1,
          identifyResult: this.goodsif.identifyResult,
          identifyDesc: this.goodsif.identifyDesc,
          createBy: this.username,
        }).then(resp => {
          alert(resp.data.message)
          this.addShopFormVisible = false;
          location.reload();
        })
        this.addShopFormVisible = false;
      },
      IsRe(row, column) {
        if (row.identifyResult == 1) {
          return "正品"
        } else {
          return "A货"
        }
      },
      IsKill(row, column) {
        if (row.stat == 1) {
          return "最新记录"
        } else {
          return "历史记录"
        }
      },
      tableRowClassName({
        row,
        rowIndex
      }) {
        if (row.stat == 1) {
          return 'warning-row'
        }
      },
      handleSizeChange(size) {

        this.getGoodsifbygid(this.current, size)

      },
      handleCurrentChange(current) {

        this.getGoodsifbygid(current, this.size);

      },
    },
    created() {
      this.getGoodsifbygid(1, 2);
    }
  }
</script>

<style>
  .el-table .warning-row {
    background: yellow;
  }


</style>
